﻿
Imports xhtmlctrl

Public Module common

    Public Function containsClass(ByVal controlClass As String, ByVal searchClass As String) As Boolean
        If isemptystring(controlClass) AndAlso isemptystring(searchClass) Then
            Return True
        ElseIf isemptystring(controlClass) OrElse isemptystring(searchClass) Then
            Return False
        Else
            '1. full match
            '2. first class match
            '3. last class match
            '4. contains a class
            Return strsame(controlClass, searchClass, True) OrElse _
                   strsame(controlClass, searchClass + character.blank, _
                           strlen(searchClass + character.blank), True) OrElse _
                   strendwith(controlClass, character.blank + searchClass, True) OrElse _
                   strcont(controlClass, character.blank + searchClass + character.blank, True)
        End If
    End Function

    Public Function containsClass(ByVal control As xhtmlControl, ByVal className As String) As Boolean
        If control Is Nothing Then
            Return False
        Else
            Return containsClass(control.class, className)
        End If
    End Function
End Module
